// OUTDOOR SECTION SCRIPT
//    Section: X = 3, Y = 2

// This is the special encounter script for this town.
// The states INIT_STATE and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.

// flags:
// 232, 2 = toadstools
// 232, 3 = energetic herbs

beginoutdoorscript;

variables;

short choice;

body;

beginstate INIT_STATE;
// This state called whenever this section is loaded into memory.
break;

beginstate START_STATE;
// Starting state of the section, called every turn the party 
// stands inside this section until you change the state.
break;

beginstate 10;
	if (get_flag(232, 0) == 0) {
		reset_dialog();
		add_dialog_str(0, "You have reached the underground world of Avernum.", 0);
		add_dialog_str(1, "This region seems wild, almost untamed, from what you can see.", 0);
		add_dialog_str(2, "Perhaps here is where you'll find what you need to rid the upperworld of the she-devil.", 0);
		add_dialog_choice(0, "OK");
		choice = run_dialog(1);
		set_flag(232, 0, 1);
	}
break;

beginstate 11;
	if (get_flag(232, 1) == 0) {
		if (has_special_item(7) > 0) {
			set_state_continue(12);
		}
		else {
			set_state_continue(13);
		}
	}
	else {
		message_dialog("The farmer and his wife welcome you into the house thanking you again for your help.", "You enjoy a meal and small talk before leaving to continue your quest.");
	}
break;

beginstate 12;
	reset_dialog();
	add_dialog_str(0, "You approach the farmhouse with the healing potion.", 0);
	add_dialog_str(1, "The farmers wife attempts to wave you off. _Infecteous person inside._ she says.", 0);
	add_dialog_str(2, "You explain you have a potion from Terra for her husband.", 0);
	add_dialog_str(3, "She gratefully accepts it and gives it to her husband.", 0);
	add_dialog_str(4, "The change is remarkable and sudden as the farmer gets up completely free of the infection.", 0);
	add_dialog_str(5, "Both of them thank you profusely before you leave.", 0);
	add_dialog_choice(0, "OK");
	choice = run_dialog(1);
	take_special_item(7);
	set_flag(232, 1, 1);
break;

beginstate 13;
	reset_dialog();
	add_dialog_str(0, "You approach the remote farmhouse.", 0);
	add_dialog_str(1, "Before you can get very far, the farmers wife waves you off.", 0);
	add_dialog_str(2, "_Don't come any closer, my husband has an infecteous desease._", 0);
	add_dialog_str(3, "You heed her warning and don't get any closer, but instead move off.", 0);
	add_dialog_choice(0, "OK");
	choice = run_dialog(1);
break;

beginstate 14;
	run_scenario_script(13);
break;

beginstate 15;
	run_scenario_script(14);
break;

beginstate 16;
	if (get_flag(232, 4) == 0) {
		set_flag(232, 4, 1);
		message_dialog("There is a passage slopping down steeply here.", "This must have been where the she-devil came from.");
	}
break;

beginstate 17;
	if (get_flag(232, 5) == 0) {
		set_flag(232, 5, 1);
		message_dialog("The passage is getting quite warm.", "");
	}
break;

beginstate 18;
	message_dialog("The passage ahead is too hot for you to continue.", "You turn back from wence you came wondering how anyone could have survived coming up this tunnel.");
	block_entry(1);
break;

beginstate 19;
	if (get_flag(232, 6) == 0) {
		set_flag(232, 6, 1);
		message_dialog("The ground looks traveled across close to the cliff here.", "Interestingly enough, the broken up ground goes right up to the cliff face and seemingly disappears.");
	}
break;
